﻿using TheOutLetLibrary.Dominio;
using System.Data.OleDb;

namespace TheOutLetLibrary.Infraestrutura {

    public class Accessk_paymentDAO: BaseDAO, IGenericDAO<k_payment> {

        public Accessk_paymentDAO(OleDbTransaction transacao)
            : base(transacao) {
        }

        public int Inclua(k_payment entity) {

            OleDbCommand comando = GetCommand();

            comando.CommandText =
                " INSERT INTO k_payment (" +
                " NR_PEDIDO, type, gateway, token) " +
                " VALUES (" +
                " @NR_PEDIDO, @type, @gateway, token)";

            comando.Parameters.Add("@NR_PEDIDO", OleDbType.Integer).Value = entity.NR_PEDIDO;
            comando.Parameters.Add("@type", OleDbType.VarChar).Value = entity.type;
            comando.Parameters.Add("@gateway", OleDbType.VarChar).Value = entity.gateway;
            comando.Parameters.Add("@token", OleDbType.VarChar).Value = entity.token;
            comando.ExecuteNonQuery();

            //comando.CommandText = "SELECT @@IDENTITY";
            //entity.COD = Convert.ToInt32(comando.ExecuteScalar());
            //return entity.COD;

            return 0;

        }

        public k_payment Ache(int Id) {
            throw new System.NotImplementedException();
        }
    }
}
